// JavaScript Document
function $(id) {
	return document.getElementById(id);
}

function save_optionskr() {
	if($('default').checked){
		localStorage['default'] = 'true';
	}else{
		localStorage['default'] = 'false';
	}

	if($('mzsegur').checked){
		localStorage['mzsegur'] = 'true';
	}else{
		localStorage['mzsegur'] = 'false';
	}

	if($('warn1').checked){
		localStorage['warn1'] = 'true';
	}else{
		localStorage['warn1'] = 'false';
	}

	if($('warn2').checked){
		localStorage['warn2'] = 'true';
	}else{
		localStorage['warn2'] = 'false';
}

	if($('warn3').checked){
		localStorage['warn3'] = 'true';
	}else{
		localStorage['warn3'] = 'false';
	}

	if($('google').checked){
		localStorage['google'] = 'true';
	}else{
		localStorage['google'] = 'false';
	}

	if($('kids').checked){
		localStorage['kids'] = 'true';
	}else{
		localStorage['kids'] = 'false';
}
// Update status to let user know options were saved.
	var status = $('status');
	status.innerHTML = chrome.i18n.getMessage('saved');
	setTimeout(function() {
		status.innerHTML = "";
	}, 1750);
}

function load_options(){
	if(localStorage['default'] == 'true')$('default').checked = true;
	if(localStorage['mzsegur'] == 'true')$('mzsegur').checked = true;

	if(localStorage['warn1'] == 'true') {
		$('warn1').checked = true;
		$('warn2').checked = false;
		$('warn3').checked = false;
	} else if(localStorage['warn2'] == 'true') {
		$('warn2').checked = true;
		$('warn1').checked = false;
		$('warn3').checked = false;
	} else if(localStorage['warn3'] == 'true') {
		$('warn3').checked = true;
		$('warn1').checked = false;
		$('warn2').checked = false;
	}
	if(localStorage['google'] == 'true')$('google').checked = true;
	if(localStorage['kids'] == 'true')$('kids').checked = true;

	document.title = chrome.i18n.getMessage("settingspagetitle");
	loadText('description', chrome.i18n.getMessage('description'));
	loadText('providerSelect', chrome.i18n.getMessage('providerSelect'));

	loadText('oneclicktext1', chrome.i18n.getMessage('oneclicktext1'));
	loadText('oneclicktext2', chrome.i18n.getMessage('oneclicktext2'));
	
	loadText('tipoalert', chrome.i18n.getMessage('tipoalert'));
	loadText('enablewarn1', chrome.i18n.getMessage('enablewarn1'));
	loadText('enablewarn2', chrome.i18n.getMessage('enablewarn2'));
	loadText('enablewarn3', chrome.i18n.getMessage('enablewarn3'));

	loadText('providerRetorno', chrome.i18n.getMessage('providerRetorno'));
	loadText('clickret1', chrome.i18n.getMessage('clickret1'));
	loadText('clickret2', chrome.i18n.getMessage('clickret2'));

	loadText('nickname', chrome.i18n.getMessage('nickname'));

	function loadText(elementId, text) {
		document.getElementById(elementId).innerText = text;
	}
}